---
title: WebContextService
summary: Contract detail for WebContextService, hosted at the `WebContext` route.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-22
---

# WebContextService

`WebContextService` implements the external `IWebContextService` contract and is activated over the `WebContext` route. This page documents every public operation the class exposes.

| Field | Value |
| --- | --- |
| **Service class** | `SAIF.Services.WCF.Services.WebContextService` |
| **Declared contract** | `IWebContextService` — external (`SAIF.Services.WCF.Contracts`, arriving transitively via `SAIF.Framework.Core`) * |
| **Route** | `WebContext` |
| **Source** | `src/WCF/SAIF.Services.WCF.Host/Services/WebContextService.cs` |
| **Service attributes** | `[AspNetCompatibilityRequirements(RequirementsMode = Allowed)]`, `[LogErrorBehavior]` |
| **Instancing / concurrency** | WCF defaults — not overridden in source |
| **Binding** | `basicHttpBinding` (default, unnamed — no `<endpoint>` is configured for any of the six routes) |
| **Class-level authorization** | None in code |
| **Error handling** | `[LogErrorBehavior]` installs `ErrorLogErrorHandler`; see [Faults and error pipeline](../faults.md) |
| **Operations** | 3 |
| **Also hosted in** | — |

---

## Get

Retrieve and consume a stored web context.

| Field | Value |
| --- | --- |
| **Operation name** | `Get` |
| **Contract name** | `Get` — override, if any, not observable because `IWebContextService` is declared in an external contracts assembly |
| **SOAP action** | Not observable — contract assembly is external |
| **Implementing member** | `SAIF.Services.WCF.Services.WebContextService.Get` (`src/WCF/SAIF.Services.WCF.Host/Services/WebContextService.cs`) |
| **Pattern** | Request/response (`IsOneWay` not observable — contract assembly is external) |
| **Binding** | `basicHttpBinding` (default, unnamed) |
| **Authorization** | [None in code](../authentication-authorization.md#authorization-enforcement) |
| **Process** | [OP-009](../operations/web-context-get.md) |

### Get input message

| Part | Type | Required | Default | Purpose |
| --- | --- | --- | --- | --- |
| `applicationName` | `string` | Yes | — | Application name portion of the context key. |
| `sessionId` | `string` | Yes | — | Session id portion of the context key. |

### Get output message

| Field | Value |
| --- | --- |
| **Return type** | `IWebContext` |
| **Meaning** | The web context for the given application and session, then destroyed. |
| **Empty-result behavior** | A newly-created context with a fresh GUID id when no `__SAIFPID` item is stored. |

### Get faults

| Fault | Declared | Raised when | Surfaced as | Detail crosses the boundary |
| --- | --- | --- | --- | --- |
| `ArgumentNullException` | Not declared | See [OP-009 process detail](../operations/web-context-get.md) | Generic SOAP fault produced by The operation itself, via `Enforce` | Yes |
| SQL Server/NHibernate exception | Not declared | See [OP-009 process detail](../operations/web-context-get.md) | Generic SOAP fault produced by The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | Yes |

<!-- No `[FaultContract]` is declared on any operation in this host — see Faults and error pipeline. -->

### Get authorization

None in code. Access to `Get` rests entirely on the IIS authentication configured for the deployment variant; see [Authentication and authorization](../authentication-authorization.md#authorization-enforcement).

### Get side effects

| Aspect | Finding |
| --- | --- |
| Records written | `WebContextItem` (read, then deleted) |
| Downstream calls | None |
| Files or messages produced | Deletes every `WebContextItem` row read for the application/session |
| Shared state touched | None |
| Repeat-call behavior | A repeat call after a successful `Get` returns a fresh context because the rows were deleted |

---

## Save

Replace the stored web context for an application and session.

| Field | Value |
| --- | --- |
| **Operation name** | `Save` |
| **Contract name** | `Save` — override, if any, not observable because `IWebContextService` is declared in an external contracts assembly |
| **SOAP action** | Not observable — contract assembly is external |
| **Implementing member** | `SAIF.Services.WCF.Services.WebContextService.Save` (`src/WCF/SAIF.Services.WCF.Host/Services/WebContextService.cs`) |
| **Pattern** | Request/response (`IsOneWay` not observable — contract assembly is external) |
| **Binding** | `basicHttpBinding` (default, unnamed) |
| **Authorization** | [None in code](../authentication-authorization.md#authorization-enforcement) |
| **Process** | [OP-010](../operations/web-context-save.md) |

### Save input message

| Part | Type | Required | Default | Purpose |
| --- | --- | --- | --- | --- |
| `applicationName` | `string` | Yes | — | Application name portion of the context key. |
| `sessionId` | `string` | Yes | — | Session id portion of the context key. |
| `context` | `IWebContext` | Yes | — | The context whose entries are persisted. |

#### Complex input types

| Type | Kind | Members | Declared in |
| --- | --- | --- | --- |
| `IWebContext` | Data contract | Not enumerated — declared in an external contracts assembly ** | `SAIF.Services.WCF.Contracts` / framework closure * |

### Save output message

| Field | Value |
| --- | --- |
| **Return type** | void |
| **Meaning** | A successful response indicates only that the operation completed without a fault. |
| **Empty-result behavior** | Not applicable. |

### Save faults

| Fault | Declared | Raised when | Surfaced as | Detail crosses the boundary |
| --- | --- | --- | --- | --- |
| `ArgumentNullException` | Not declared | See [OP-010 process detail](../operations/web-context-save.md) | Generic SOAP fault produced by The operation itself, via `Enforce` | Yes |
| SQL Server/NHibernate exception | Not declared | See [OP-010 process detail](../operations/web-context-save.md) | Generic SOAP fault produced by The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | Yes |

<!-- No `[FaultContract]` is declared on any operation in this host — see Faults and error pipeline. -->

### Save authorization

None in code. Access to `Save` rests entirely on the IIS authentication configured for the deployment variant; see [Authentication and authorization](../authentication-authorization.md#authorization-enforcement).

### Save side effects

| Aspect | Finding |
| --- | --- |
| Records written | `WebContextItem` (delete all, then insert) |
| Downstream calls | None |
| Files or messages produced | Deletes and reinserts the full `WebContextItem` set for the application/session |
| Shared state touched | None |
| Repeat-call behavior | Idempotent — replaces the full stored set each time |

---

## CreateContext

Construct a new in-memory web context.

| Field | Value |
| --- | --- |
| **Operation name** | `CreateContext` |
| **Contract name** | `CreateContext` — override, if any, not observable because `IWebContextService` is declared in an external contracts assembly |
| **SOAP action** | Not observable — contract assembly is external |
| **Implementing member** | `SAIF.Services.WCF.Services.WebContextService.CreateContext` (`src/WCF/SAIF.Services.WCF.Host/Services/WebContextService.cs`) |
| **Pattern** | Request/response (`IsOneWay` not observable — contract assembly is external) |
| **Binding** | `basicHttpBinding` (default, unnamed) |
| **Authorization** | [None in code](../authentication-authorization.md#authorization-enforcement) |
| **Process** | [OP-011](../operations/web-context-createcontext.md) |

### CreateContext input message

| Part | Type | Required | Default | Purpose |
| --- | --- | --- | --- | --- |
| `contextId` | `string` | No | — | Seed value for the new context's id; a blank value produces a fresh GUID instead. |

### CreateContext output message

| Field | Value |
| --- | --- |
| **Return type** | `IWebContext` |
| **Meaning** | A new, unpersisted web context carrying the given or generated id. |
| **Empty-result behavior** | Not applicable. |

### CreateContext faults

| Fault | Declared | Raised when | Surfaced as | Detail crosses the boundary |
| --- | --- | --- | --- | --- |
| — | Not declared | — | — | — |

<!-- No `[FaultContract]` is declared on any operation in this host — see Faults and error pipeline. -->

### CreateContext authorization

None in code. Access to `CreateContext` rests entirely on the IIS authentication configured for the deployment variant; see [Authentication and authorization](../authentication-authorization.md#authorization-enforcement).

### CreateContext side effects

| Aspect | Finding |
| --- | --- |
| Records written | None |
| Downstream calls | None |
| Files or messages produced | None — no persistence occurs |
| Shared state touched | None |
| Repeat-call behavior | Idempotent when `contextId` is supplied; produces a new id each call otherwise |


---

## Coverage checklist

| Public member | Documented section | Pattern |
| --- | --- | --- |
| `IWebContext Get(string applicationName, string sessionId)` | [`Get`](#get) | Request/response |
| `void Save(string applicationName, string sessionId, IWebContext context)` | [`Save`](#save) | Request/response |
| `IWebContext CreateContext(string contextId)` | [`CreateContext`](#createcontext) | Request/response |

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Activation and hosting](../activation-hosting.md)
- [Operations](../operations.md)
- [Faults and error pipeline](../faults.md)
- [Authentication and authorization](../authentication-authorization.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)
- [Operational runbook](../operational-runbook.md)
- [Tech debt](../tech-debt.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- src/WCF/SAIF.Services.WCF.Host/Services/WebContextService.cs
